﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartSpace.Core;

namespace SsTool.Base.Windows
{
    /// <summary>
    /// UpdateRoleWindow.xaml 的交互逻辑
    /// </summary>
    public partial class UpdateRoleWindow : Window
    {
        private Role _role;
        public UpdateRoleWindow(Role role)
        {
            InitializeComponent();
            _role = role;
            ShowUser(_role);
        }

        private void ShowUser(Role role)
        {
            this.DataContext = role;
        }

        public void UpdateRole(Role role)
        {
            ICoreService service = App.Get<ICoreService>();
            if (service.StoreRole(role))
            {
                DialogResult = true;
                return;
            }
            MessageBox.Show("保存失败!");
        }

        private void _ctlBtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            UpdateRole(_role);
        }
    }
}
